package com.xinghuo.building.ui.component.splash

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import com.xinghuo.building.R
import com.xinghuo.building.SPLASH_DELAY
import com.xinghuo.building.databinding.SplashLayoutBinding
import com.xinghuo.building.ui.base.BaseActivity
import com.xinghuo.building.ui.base.BaseViewModel
import com.xinghuo.building.ui.component.login.LoginActivity
import dagger.hilt.android.AndroidEntryPoint

/**
 * Created by chendaning
 */
@AndroidEntryPoint
class SplashActivity : BaseActivity<SplashLayoutBinding>(){

    override fun getLayoutId(): Int {
        return R.layout.splash_layout
    }

    override fun getViewModel(): BaseViewModel? {
        return null
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        navigateToMainScreen()
    }

    override fun observeViewModel() {
    }

    private fun navigateToMainScreen() {
        Handler().postDelayed({
            val nextScreenIntent = Intent(this, LoginActivity::class.java)
            logger.info("SplashActivity", "delay time=" + SPLASH_DELAY.toLong())
            startActivity(nextScreenIntent)
            finish()
        }, SPLASH_DELAY.toLong())
    }
}
